<script setup lang="ts">
import { useRouter } from 'vue-router'
import { ArrowDown, CopyDocument, Delete, Edit, Plus, Search } from '@element-plus/icons-vue'
import { DATA_FLOW_DESIGN_PATH, DEV_TOOL_FUNCTION_DESIGN_FUNCTION_LIST_PATH } from '@/router'

const router = useRouter()

const data = [
  {
    id: 1,
    name: '基础算子包',
    functionNumber: 10,
    createTime: '2023-01-01 12:00:00',
    updateTime: '2023-01-01 12:00:00'
  }
]
</script>

<template>
  <el-card class="function-design-project-list">
    <template #header>
      <div class="list-header">
        <div class="left-bar">
          <el-dropdown>
            <el-button type="primary">
              批量操作
              <el-icon class="el-icon--right">
                <arrow-down />
              </el-icon>
            </el-button>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item :icon="Delete as any">删除</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
        <div class="right-bar">
          <el-input size="default" placeholder="请输入关键字">
            <template #append>
              <el-button size="default" :icon="Search as any" />
            </template>
          </el-input>
          <el-button
            size="default"
            type="primary"
            @click="
              router.push({
                path: DEV_TOOL_FUNCTION_DESIGN_FUNCTION_LIST_PATH
              })
            "
          >
            新建
            <el-icon class="el-icon--right">
              <plus />
            </el-icon>
          </el-button>
        </div>
      </div>
    </template>
    <el-table :data="data" style="width: 100%">
      <el-table-column type="selection" width="40" />
      <el-table-column prop="id" label="ID" width="50" />
      <el-table-column prop="name" label="名称" width="180" />
      <el-table-column prop="functionNumber" label="算子数量" />
      <el-table-column prop="createTime" sortable label="创建时间" />
      <el-table-column prop="updateTime" sortable label="修改时间" />
      <el-table-column fixed="right" label="操作" width="160">
        <template #default="scope">
          <el-tooltip effect="dark" content="编辑" placement="top">
            <el-button
              type="primary"
              size="small"
              circle
              :icon="Edit as any"
              @click="
                router.push({
                  path: DEV_TOOL_FUNCTION_DESIGN_FUNCTION_LIST_PATH,
                  query: {
                    name: scope.row.name
                  }
                })
              "
            ></el-button>
          </el-tooltip>
          <el-tooltip effect="dark" content="复制" placement="top">
            <el-button color="#0097e6" size="small" circle :icon="CopyDocument as any"></el-button>
          </el-tooltip>
          <el-tooltip effect="dark" content="删除" placement="top">
            <el-button type="danger" size="small" :icon="Delete as any" circle />
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      style="margin-top: 15px; justify-content: flex-end"
      :small="true"
      background
      layout="prev, pager, next"
      :total="1000"
    />
  </el-card>
</template>

<style scoped lang="scss">
.function-design-project-list {
  .list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    .right-bar {
      display: flex;
      align-items: center;

      > div {
        margin: 0 5px;
      }
    }
  }
}
</style>
